program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, a, j: integer;
  f: boolean;

begin
  read (n);
  for i := 0 to n - 1 do
    for j := 0 to n - 1 do
    begin
      read (a);
      if (i=j) and (a=1) then
        f:= true;
    end;
  if f then
    write ('YES')
  else
    write ('NO');
end.
